package com.sqx.modules.userGetPhoneRecord.controller;

import com.sqx.modules.app.annotation.Login;
import com.sqx.modules.userGetPhoneRecord.service.IUserGetPhoneRecordService;
import com.sqx.modules.userGetPhoneRecord.vo.UserGetPhoneRecordVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.sqx.common.utils.Result;

/**
 * 用户购买记录表
 *
 * @author wuchang
 * @since 2023-07-05
 */
@RestController
@RequestMapping("/app/userGetPhoneRecord/")
@Api(value = "用户购买记录表", tags = {"用户购买记录表"})
public class UserGetPhoneRecordController {
    @Autowired
    private IUserGetPhoneRecordService getPhoneRecordService;

    @Login
    @ApiOperation("购买发布人手机号")
    @PostMapping("buyPhone")
    public Result buyPhone(@RequestAttribute("userId") Long userId, Long postPushId) {
        return getPhoneRecordService.buyPhone(userId, postPushId);
    }

    @Login
    @ApiOperation("获取发布人电话")
    @GetMapping("getPostPushPhone")
    public Result getPostPushPhone(@RequestAttribute("userId") Long userId, Long postPushId) {
        return getPhoneRecordService.getPostPushPhone(userId, postPushId);
    }

    @Login
    @ApiOperation("获取我的购买记录")
    @GetMapping("getByPhoneList")
    public Result getByPhoneList(@RequestAttribute("userId")Long userId, Integer page, Integer limit, UserGetPhoneRecordVo phoneRecordVo) {
        phoneRecordVo.setUserId(userId);
        return Result.success().put("data", getPhoneRecordService.getByPhoneList(page, limit,phoneRecordVo));
    }
}
